package com.hxs.hxsserver.enums;

/**
 * @author liuchuan
 * @create 2024/11/19
 */
public enum RelayModeEnums {
    MANUAL(1, "手动"),
    AUTO(2, "自动"),
    FIXED_POINT(3, "定点"),
    WEEKLY(4, "星期");

    private final int code; // 模式代码
    private final String description; // 模式描述

    // 构造函数
    RelayModeEnums(int code, String description) {
        this.code = code;
        this.description = description;
    }

    // 获取模式代码
    public int getCode() {
        return code;
    }

    // 获取模式描述
    public String getDescription() {
        return description;
    }

    // 根据代码获取对应的模式
    public static RelayModeEnums fromCode(int code) {
        for (RelayModeEnums mode : RelayModeEnums.values()) {
            if (mode.getCode() == code) {
                return mode;
            }
        }
        throw new IllegalArgumentException("Unknown mode code: " + code);
    }
}
